package org.huawei260.TiKu.ODsuanfa;

/**
 * @Author: qingle
 * @Date: 2024/10/28-16:11
 * @Description: 4202 【前缀和】2024E数字游戏
 * @version: 1.0
 */

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
public class E_2024E_4202__前缀和数字游戏 {

//	public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);

			while (sc.hasNextLine()) {
				try {
					int[] tmp = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
					int[] nums = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
					System.out.println(isExist(nums, tmp[1]));
				} catch (Exception e) {
					break;
				}
			}
		}

		public static int isExist(int[] nums, int m) {
			HashSet<Integer> remain = new HashSet<>();
			remain.add(0);

			int sum = 0;
			for (int num : nums) {
				sum += num;
				if (remain.contains(sum % m)) {
					return 1;
				} else {
					remain.add(sum % m);
				}
			}

			return 0;
		}
	}